package com.whzm.mq;

import com.whzm.service.IRedisService;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: rate-of-flow
 * @BelongsPackage: com.whzm.mq
 * @Author: 吴严
 * @CreateTime: 2020-08-24 15:58
 * @Description:
 */
@Component
public class ResourceListener {

    @Autowired
    private IRedisService redisService;

    @Autowired
    private RedisTemplate redisTemplate;

//    @RabbitListener(queuesToDeclare = @Queue("spring-mysql-to-es"))
//    public void resourceListener(String msg) {
//        System.out.println("文胸牛皮");
//        //先获取到消息中的主键（id）和操作类型
//        String[] msgs = msg.split("-");
//        String id = msgs[0];
//        System.out.println("-----------------------" + id);
//        String type = msgs[1];
//        if (type.equals("insert") || type.equals("update")) {
//            ResourceESVo resourceESVo = (ResourceESVo) redisTemplate.opsForValue().get(id);
//            System.out.println("---------------------" + resourceESVo.toString());
//
//            resourceEsService.save(resourceESVo);
//            System.out.println("---------------------es存储成功");
//
//        } else if (type.equals("delete")) {
//
//        }
//    }
}
